home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / ANSIshellƒ / os_mac_str.c < prev    next >
Encoding:
Text File  |  1994-09-30  |  1.1 KB  |  46 lines  |  [TEXT/R*ch]

  1. // os_mac_str.c
  2. // 30Sep94 e (from os_mac.c originally by Marc Feeley)
  3. // portions Copyright © 1992 Marc Feeley and Douglas H. Currie, Jr.
  4.  
  5. #include <Types.h>
  6. #include "os_mac_str.h"
  7.  
  8. void c_to_p( char * c_str, Str255 p_str )
  9. { short i = 0;
  10.   while (c_str[i] != '\0') { p_str[i+1] = c_str[i]; i++; }
  11.   p_str[0] = i;
  12. }
  13.  
  14. void p_to_p( Str255 p1, Str255 p2 )
  15. { short len = (unsigned char)*p1++;
  16.   *p2++ = len;
  17.   while (len>0) { *p2++ = *p1++; len--; }
  18. }
  19.  
  20. void buf_to_p( unsigned short len, char *p1, Str255 p2 )
  21. { if( len > 255 ) len = 255;
  22.   *p2++ = len;
  23.   while (len>0) { *p2++ = *p1++; len--; }
  24. }
  25.  
  26. void p_to_c( Str255 p_str, char *c_str )
  27. { short len = (unsigned char)*p_str++, i = 0;
  28.   while (i<len) { *c_str++ = *p_str++; i++; }
  29.   *c_str++ = '\0';
  30. }
  31.  
  32. short compare_p_to_p( Str255 p1, Str255 p2 )
  33. { short len1 = (unsigned char)*p1++, len2 = (unsigned char)*p2++;
  34.   if (len1 < len2) return -1;
  35.   if (len1 > len2) return 1;
  36.   while (len1>0)
  37.   { short c1 = (unsigned char)*p1++, c2 = (unsigned char)*p2++;
  38.     if (c1 < c2) return -1;
  39.     if (c1 > c2) return 1;
  40.     len1--;
  41.   }
  42.   return 0;
  43. }
  44.  
  45. // end
  46.